/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 */
package com.apache.order.service.plugins;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.cache.util.Validator;
import com.apache.order.manager.TOrderDetailManager;
import com.apache.order.manager.TOrderManager;

/**
 * description:  删除订单插件
 * @author Hou Dayu 创建时间：2015-8-3  
 */
public class DeleteOrderPluginImpl implements PluginConnector {

	private TOrderManager tOrderManager;
	private TOrderDetailManager tOrderDetailManager;

	/**
	 * TODO 删除订单插件实现.  
	 * @see com.dwusoft.api.manager.PluginConnector#execute(com.dwusoft.api.vo.ParamsVo)  
	 */
	public Object execute(ParamsVo param) throws Exception {

		String orderId = param.getInfoId();
		if (Validator.isNotNull(orderId)) {
			ParamsVo vo = new ParamsVo();
			vo.setInfoId(orderId);
			boolean mark = tOrderManager.deleteInfo(vo);
			if (mark) {
				vo.setMethodKey("ByOrderId");
				mark = tOrderDetailManager.deleteInfo(vo);
				param.setParams("content", "删除订单信息");
				param.setParams("logType", "del");
				param.setParams("logTitle", "删除订单信息");
				OrderEnginePluginUtil.newFixed().saveLogMessage(param);
			}
			return mark;
		}
		return false;
	}

	public void settOrderManager(TOrderManager tOrderManager) {
		this.tOrderManager = tOrderManager;
	}

	public void settOrderDetailManager(TOrderDetailManager tOrderDetailManager) {
		this.tOrderDetailManager = tOrderDetailManager;
	}
}
